<template>
  <div>
    <t-form ref="form" class="step-form"
            labelWidth="120px" :colon="true">
      <t-row style="flex: 1">
        <t-col :span="12">
          <t-card class="step-card" size="small" title="推广基本信息">
            <t-form-item label="成果名称" name="name">
              {{ objData.name }}
            </t-form-item>
            <t-form-item label="成果类别" name="achievementType">
              {{ objData.achievementType | filterByDict(dict.type.achievement_type) }}
            </t-form-item>
            <t-form-item label="研发单位" name="createCompany">
              {{ objData.createCompany }}
            </t-form-item>
            <t-form-item label="验收时间" name="accepentDate">
              {{ objData.accepentDate }}
            </t-form-item>
            <t-form-item label="填报单位" name="declareDeptName">
              {{ objData.declareDeptName }}
            </t-form-item>
          </t-card>
          <t-card class="step-card" size="small" title="推广项目列表">
            <extend-project ref="extend-project" v-model="objData.extendLists"
            ></extend-project>
          </t-card>
        </t-col>
      </t-row>
    </t-form>
  </div>
</template>

<script>
import { VITE_FILE_DOMAIN } from '@/api/upload'
import extendProject from "./extend-project.vue";

export default {
  name: "extend-detail",
  dicts: ['achievement_type'],
  components: {
    extendProject,
  },
  props: {
    objId: [String, Number],
    achievementType: String,
  },
  data() {
    return {
      site_tag: import.meta.env.VITE_SITE_TAG,
      file_domain: VITE_FILE_DOMAIN,
      tabValue: '1',
      objData: {},
    }
  },
  watch: {
    objId: {
      immediate: true,
      handler(val) {
        if (val) {
          this.getObj(val);
        }
      }
    },
  },
  methods: {
    getObj() {
      this.$api.cgzh.extend.getByAchievementTypeAndId({
        achievementType:this.achievementType,
        achievementId:this.objId,
      }).then(response => {
        this.objData = response.data;
      }).catch((e) => {
        this.$message.error(e.toString());
      });
    }
  }
}
</script>

<style lang="less" scoped>
.t-tab-panel {
  padding: 10px;
}

.t-form__item {
  margin-bottom: 6px
}

.step-card {
  margin-bottom: 14px;
}
</style>
